package com.cellulam.framework.core.auth;

public interface UserClient {

    String USER_ATTRIBUTE_NAME = "LOGIN_USER";

    long DEFAULT_USER_ID = 0;

    default long getUserId() {
        UserBasicInfo userBasicInfo = this.getUser();
        return userBasicInfo == null ? DEFAULT_USER_ID : userBasicInfo.getUserId();
    }

    default String getAccessToken() {
        UserBasicInfo userBasicInfo = this.getUser();
        return userBasicInfo == null ? null : userBasicInfo.getAccessToken();
    }

    default String getAccessToken(long userId) {
        UserBasicInfo userBasicInfo = this.getUserById(userId);
        return userBasicInfo == null ? null : userBasicInfo.getAccessToken();
    }

    default String getUserName(long userId) {
        UserBasicInfo user = this.getUserById(userId);
        return user == null ? null : user.getUsername();
    }

    default String getRealName(long userId) {
        UserBasicInfo user = this.getUserById(userId);
        return user == null ? null : user.getRealName();
    }

    UserBasicInfo getUser();

    UserBasicInfo getUserBasicInfo(String accessToken);

    UserBasicInfo getUserById(long userId);
}
